package demo.practice.competition;

import java.util.Stack;

public class P1837 {

    public static void main(String[] args) {
        P1837 p1837= new P1837();
        int i = p1837.sumBase(34, 6);
        System.out.println(i);
    }
    public int sumBase(int n, int k) {

        Stack<Integer> stack= new Stack<>();

        while (n>0){
            stack.add(n%k);
            n=n/k;
        }

        int sum=0;
        for (Integer i : stack) {
            sum+=i;
        }
        return sum;
    }
}
